/**********************************************************************/
/*
   Author: Karan Makkar
   Created: Jan 2025
   Description: Anonymized province ID
   Inputs:
   $KP_deid_susenas/Raw/provid_java_crosswalk
   Outputs:
   provid_anon_crosswalk.dta
*/
/**********************************************************************/

/*----------------------------------------------------*/
* Section: Setup
/*----------------------------------------------------*/

* include filepaths 
if "$master_run" !="1" include "./Do/SET_FILEPATHS.do"

clear all
set more off
set matsize 11000

* Log
cap log close
global prefix: display %tdCYND td(`c(current_date)')
log using "$KP_logs/${prefix}_provid_anonymize.txt", text replace
set seed 123456

u "$KP_deid_susenas/Raw/provid_java_crosswalk", clear

gen anon_prov_id = runiformint(100, 10000)
gen prov_id_sus = prov_id
gen anon_prov_id_ssus = anon_prov_id
gen prov_id_sak = prov_id
gen anon_prov_id_sak = anon_prov_id
gen prov_id_21 = prov_id
gen anon_prov_id_21 = anon_prov_id

* Save anonymized crosswalk
datasignature 
if "`r(datasignature)'" == "34:9(23330):2522911278:3927924157" {
    sa "${KP_deid_misc}/Clean/provid_anon_crosswalk.dta", replace
      }
  else {
    di as err "Careful, your machine produces a different dataset"
    stop
		}
